package b2.widget.login
{
	import b2.net.*;
	import b2.widget.*;
	
	import flash.display.Sprite;
	import flash.events.*;
	import flash.filters.*;
	import flash.text.*;
	
	public class AwardMessage extends Sprite
	{
		public function AwardMessage(topMessage:String, bottomMessage:String, items:Array)
		{
			super();
			var MessageBoxGgr:Class = ResourceHelper.getInstance().getClassByName("MessageBox0");
			var mainSprite:Sprite = new MessageBoxGgr();
			mainSprite.alpha = alpha;
			addChild(mainSprite);

			//信息文字
			var messageText:TextField = new TextField();
			messageText.selectable = false;
        	messageText.autoSize = TextFieldAutoSize.CENTER;
			messageText.defaultTextFormat = new TextFormat("微软雅黑", 15, 0x000000, true);;
//			messageText.filters = [new GlowFilter(0x000000, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			messageText.htmlText = topMessage;
			messageText.x = 40;
			messageText.y = 55;
			addChild(messageText);
			
			var giftContainer:Sprite = new Sprite();
			//添加得到的奖励
			for (var i:int = 0; i < Math.min(items.length, 3); i++)
			{
				var giftItem:GiftItem = items[i] as GiftItem;
				giftItem.x = i * (giftItem.width + 3);
				giftItem.y = 0;
				giftContainer.addChild(giftItem);
			}
			giftContainer.x = (this.width - giftContainer.width) / 2;
			giftContainer.y = messageText.y + messageText.height + 10;
			addChild(giftContainer);
			
			var messageText2:TextField = new TextField();
			messageText2.selectable = false;
        	messageText2.autoSize = TextFieldAutoSize.CENTER;
			messageText2.defaultTextFormat = new TextFormat("微软雅黑", 15, 0x000000);
			messageText2.wordWrap = true;
			messageText2.width = 360;
//			messageText2.filters = [new GlowFilter(0x000000, 1, 1.3, 1.3, 100, BitmapFilterQuality.HIGH)];
			messageText2.htmlText = bottomMessage;
			messageText2.x = 40;
			messageText2.y = messageText.y + messageText.height + 80;
			addChild(messageText2);
			
			//分享按钮
			var ButtonBgr:Class = ResourceHelper.getInstance().getClassByName("ButtonBgr1");
			var buttonShare:BasicButton = new BasicButton(ButtonBgr, "分享");
			buttonShare.x = (mainSprite.width  - buttonShare.width) / 4;
			buttonShare.y = mainSprite.height - buttonShare.height - 20;
			buttonShare.addEventListener(MouseEvent.CLICK, onButtonShareClick);
			addChild(buttonShare);
			
			//确定按钮
			var buttonOK:BasicButton = new BasicButton(ButtonBgr, "确定");
			buttonOK.x = (mainSprite.width  - buttonOK.width) * 3 / 4;
			buttonOK.y = mainSprite.height - buttonOK.height - 20;
			buttonOK.addEventListener(MouseEvent.CLICK, onButtonOKClick);
			addChild(buttonOK);
		}
		
		//点击分享
		private function onButtonShareClick(event:MouseEvent):void
		{
			RRApiHelper.sendFeed("正在坦克要塞开坦克~");
			close();
		}
		
		private function onButtonOKClick(event:MouseEvent):void
		{
			close();
		}
		
		public function close():void
        {
        	if (this.parent != null)
        	{
        		this.parent.removeChild(this);
        	}
        }
	}
}